package com.xiaxueqi.web.shop;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;

import com.niagara.service.base.BaseService;
import com.xiaxueqi.entity.book.BookComment;
import com.xiaxueqi.entity.book.BookForsaleExt;
import com.xiaxueqi.entity.security.AppUserDetail;

public class BookDetailAction {

	@Autowired
	private BaseService baseService;
	private Integer id;
	private BookForsaleExt bookDetail;// 书的详细信息
	private List<BookComment> commentList;// 推荐评论
	private AppUserDetail userDetail;

	@SuppressWarnings("unchecked")
	public String execute() {
		bookDetail = this.baseService.get(BookForsaleExt.class, id);
		Map map = new HashMap();
		map.put("bookId", bookDetail.getBookId());
		map.put("start", 0);
		map.put("pageSize", 5);
		map.put("orderByClause", "create_time desc");
		commentList = this.baseService.find(BookComment.class, map);
		userDetail = this.baseService.get(AppUserDetail.class, bookDetail.getOwnerId());
		return "success";
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public BookForsaleExt getBookDetail() {
		return bookDetail;
	}

	public List<BookComment> getCommentList() {
		return commentList;
	}

	public void setBaseService(BaseService baseService) {
		this.baseService = baseService;
	}

	public AppUserDetail getUserDetail() {
		return userDetail;
	}
}
